<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>账号登录</title>
    <link   rel="stylesheet"        th:href="@{/easyui/themes/default/easyui.css}" />
    <link   rel="stylesheet"        th:href="@{/easyui/themes/icon.css}" />
    <link   rel="stylesheet"        th:href="@{/libs/FakeLoader/fakeLoader.css}"/>
    <script type="text/javascript"  th:src="@{/easyui/jquery.min.js}" ></script>
    <script type="text/javascript"  th:src="@{/easyui/jquery.easyui.min.js}" ></script>
    <script type="text/javascript"  th:src="@{/libs/FakeLoader/fakeLoader.min.js}" ></script>
    <script type="text/javascript"  th:src="@{/libs/backstretch/jquery.backstretch.min.js}" ></script>
</head>
    <body>
    <div id="fakeLoader"></div>
    <div style="width:400px;margin: 10px auto; margin-top: 300px">
        <div class="easyui-panel" title="账号登录" style="width: 100%;padding: 10px;">
            <form id="login_form" method="post" th:action="@{/login}">
                <div style="margin-bottom:10px">
                    <input class="easyui-textbox" name="loginName" style="width:100%" data-options="label:'账号:',required:true">
                </div>
                <div style="margin-bottom:10px">
                    <input class="easyui-textbox" name="loginPwd" style="width:100%" data-options="label:'密码:',required:true,type:'password'">
                </div>
            </form>
            <div style="text-align:center;padding:5px 0">
                <a href="javascript:void(0)" class="easyui-linkbutton" onclick="submitForm()">登录</a>
                <a href="javascript:void(0)" class="easyui-linkbutton" onclick="clearForm()">清空</a>
            </div>
        </div>
    </div>
    <script>
        $("#fakeLoader").fakeLoader();
        $.backstretch([
            "images/bg/001.jpg",
            "images/bg/002.jpg",
            "images/bg/003.jpg",
            "images/bg/004.jpg",
            "images/bg/005.jpg"
        ], {duration: 4000});
        function submitForm(){
            var postData = $("#login_form").serialize();
            $.ajax({
                url: "./login",
                //同步方式
                async: false,
                data: postData,
                dataTye:"json",
                type: "POST",
                //指定请求成功后执行的回调函数
                success: function(data){
                    console.info(data)
                    //alert("coce:["+data.code+"],msg:["+data.msg+"]");
                    $.messager.alert("提示",data.msg,"info");
                    if(data && data.code == 1){
                        window.location.href="./main/";
                    }
                    //window.location.href="/main/index";
                },
                error: function(err){
                    console.info(err)
                    //alert("error");
                    $.messager.alert("提示","登录错误","error");
                }
            });
            //$('#login_form').form('submit');
        }
        function clearForm(){
            $('#login_form').form('clear');
        }
    </script>
    </body>
</html>